<?php
namespace app\api\controller;

use app\BaseController;

use app\common\model\AtlasModel;
class Atlas extends BaseController{
    
    public function list(){
        $category_id = $this->request->param('category_id/d',0);
        $where=[
            ['is_delete','=',0]
        ];
        
        if($category_id > 0){
            $where[] = ['category_id','=',$category_id];
        }else{
            $where[] = ['firm_id','=',$this->request->staff_info->firm_id];
        }

        $list = AtlasModel::field('atlas_id,thumbnail,title,desc,atlas')->where($where)
            ->limit($this->request->limit)
            ->page($this->request->page)
            ->order('sort','desc')
            ->select();
        return success($list);
    }
    
    public  function detail(){
        $atlas_id = $this->request->param('atlas_id/d',0);
        if(empty($atlas_id)){
            return error('错误操作');
        }
        if(null === $atlasModel = AtlasModel::find($atlas_id)){
            return error('内容不存在');
        }
        return success($atlasModel);
    }
}